/**
 * 文件名:PrefUtil.java
 * 创建时间:2014-7-9
 * 所在包:
 * 作者:李永富
 * 说明:ShredPreferences数据存取的通用工具类
 */
package com.windystory.wslibrary.util;

import android.content.Context;
import android.content.SharedPreferences;

public class PrefUtil {
    public static final String PrefName = "PrefUtil";

    public static boolean getPrefBoolean(Context context, String key, boolean v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        return settings.getBoolean(key, v);
    }

    public static void setPrefBoolean(Context context, String key, boolean v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(key, v);
        editor.commit();
    }

    public static long getPrefLong(Context context, String preferenceName, String key, long v) {
        SharedPreferences settings = context.getSharedPreferences(preferenceName, 0);
        return settings.getLong(key, v);
    }

    public static long getPrefLong(Context context, String key, long v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        return settings.getLong(key, v);
    }

    public static void setPrefLong(Context context, String key, long v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putLong(key, v);
        editor.commit();
    }

    public static void setPrefLong(Context context, String preferenceName, String key, long v) {
        SharedPreferences settings = context.getSharedPreferences(preferenceName, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putLong(key, v);
        editor.commit();
    }

    public static void setPrefInt(Context context, String key, int v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(key, v);
        editor.commit();
    }

    public static int getPrefInt(Context context, String key, int v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        return settings.getInt(key, v);
    }

    public static String getPrefString(Context context, String key, String v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        return settings.getString(key, v);
    }

    public static String getPrefString(Context context, String preferenceName, String key, String v) {
        SharedPreferences settings = context.getSharedPreferences(preferenceName, 0);
        return settings.getString(key, v);
    }

    public static void setPrefString(Context context, String key, String v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(key, v);
        editor.commit();
    }

    public static void setPrefString(Context context, String preferenceName, String key, String v) {
        SharedPreferences settings = context.getSharedPreferences(preferenceName, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(key, v);
        editor.commit();
    }

    public static float getPrefFloat(Context context, String key, float v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        return settings.getFloat(key, v);
    }

    public static void setPrefFloat(Context context, String key, float v) {
        SharedPreferences settings = context.getSharedPreferences(PrefName, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putFloat(key, v);
        editor.commit();
    }


}
